<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Vaccine extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'eb_vaccine';
    public $timestamps = false;
    public static function typeLabels($k,$v){
        $vaccines=Vaccine::all()->toArray();
        $key=array_column($vaccines,$k);
        $value=array_column($vaccines,$v);
        return array_combine($key,$value);
    }
    public static function booted()
    {
        parent::booted();
        static::creating(function ($model){
            if(empty($model->intro)){
                $model->intro = '';
            }
        });
        static::updating(function ($model){
            if(empty($model->intro)){
                $model->intro = '';
            }
        });
    }
    public function type()
    {
        return $this->hasOne(VaccineType::class,'id','type_id');
    }
}
